package testGit;

import java.io.IOException;

import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.FileAppender;
import org.apache.log4j.HTMLLayout;
import org.apache.log4j.Level;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.RollingFileAppender;
import org.apache.log4j.SimpleLayout;
import org.apache.log4j.spi.LoggerFactory;

public class test01 {
	private static Logger logger = Logger.getLogger(test01.class);
	
	public static void main(String[] args) throws IOException{
		
		PatternLayout pattern = new PatternLayout("时间：%d{yyyy-MM-dd HH:mm:ss}%n"
				+ "日志输出的行：%L%n"
				+ "日志输出的位置：%l%n"
				+ "日志输出的方法：%M%n"
				+ "日志的级别：%p%n"
				+ "日志的内容：%m%n"
				+ "类名：%c%n"
				+ "线程名：%t");
		ConsoleAppender console = new ConsoleAppender(pattern);
		FileAppender file = new FileAppender(pattern, "123.log");
		logger.addAppender(file);
		logger.addAppender(console);
		DBAppender db = new DBAppender();
		logger.addAppender(db);
		logger.setLevel(Level.ERROR);
		logger.debug("这是调试信息");
		logger.info("这是普通信息");
		logger.warn("这是警告信息");
		logger.error("这是错误信息");
		logger.fatal("这是严重错误信息");
	}
}
